---
title: "Untitled"
output: html_document
---
############################################
Title: 3_05_Figure_5.rmd
Purpose: This code creates Figure 5.
Last updated: 25-04-2023

Input:
    - Baseline macro data. Latest version: final_agg_macro_data_monthly.csv 
    
Output:
    - Figure 5
    
##########################################


0. Setup *Set your file path here*
```{r, results="hide", include=FALSE}
#Clear user defined environment
rm(list=ls())
#Clear memory
gc()

#Load packages
require(pacman)
p_load(dplyr, tidyverse, readxl, ggplot2, tidylog, magrittr,sandwich, lmtest, psych, lm.beta, stargazer)

#options
options(digits=5)
options(stringsAsFactors = FALSE)
options(scipen=999)

#Assign dplyr verbs  
select <- dplyr::select
rename <- dplyr::rename
mutate <- dplyr::mutate
filter <- dplyr::filter
arrange <- dplyr::arrange
distinct <- dplyr::distinct
group_by <- dplyr::group_by
summarise <- dplyr::summarise
list <- base::list

#Define directories
global <- ".../2024_RFS_Replication_TOSUBMIT"

```



########################################## 
1. Setup data
##########################################

1.1 Load data
```{r, results="hide", include=FALSE}

#Load
final_agg_macro <- read_csv(paste0(global, "/Data/final_agg_macro_data_monthly.csv", ""), 
      col_types = cols(...1 = col_skip(), date = col_date(format = "%Y-%m-%d")))

```

1.2 Add growth rates (h = 1-12)
```{r, results="hide", include=FALSE}
lead <- dplyr::lead
lag <- dplyr::lag

#Create returns and lag variables:
final_agg_macro = final_agg_macro %>%
  #ind prod
  mutate(lip_1m_ahead = lead(lip, n=1) - lag(lip, n=1)) %>%
  mutate(lip_2m_ahead = lead(lip, n=2) - lag(lip, n=1)) %>%
  mutate(lip_3m_ahead = lead(lip, n=3) - lag(lip, n=1)) %>%
  mutate(lip_4m_ahead = lead(lip, n=4) - lag(lip, n=1)) %>%
  mutate(lip_5m_ahead = lead(lip, n=5) - lag(lip, n=1)) %>%
  mutate(lip_6m_ahead = lead(lip, n=6) - lag(lip, n=1)) %>%
  mutate(lip_7m_ahead = lead(lip, n=7) - lag(lip, n=1)) %>%
  mutate(lip_8m_ahead = lead(lip, n=8) - lag(lip, n=1)) %>%
  mutate(lip_9m_ahead = lead(lip, n=9) - lag(lip, n=1)) %>%
  mutate(lip_10m_ahead = lead(lip, n=10) - lag(lip, n=1)) %>%
  mutate(lip_11m_ahead = lead(lip, n=11) - lag(lip, n=1)) %>%
  mutate(lip_12m_ahead = lead(lip, n=12) - lag(lip, n=1)) %>%
  mutate(lip_1m_behind = lag(lip, n=1) - lag(lip, n=2) ) %>%
  #Business Inventory
  mutate(linv_1m_ahead = lead(linv, n=1) - lag(linv,n=1)) %>%
  mutate(linv_2m_ahead = lead(linv, n=2) - lag(linv,n=1)) %>%
  mutate(linv_3m_ahead = lead(linv, n=3) - lag(linv,n=1)) %>%
  mutate(linv_4m_ahead = lead(linv, n=4) - lag(linv,n=1)) %>%
  mutate(linv_5m_ahead = lead(linv, n=5) - lag(linv,n=1)) %>%
  mutate(linv_6m_ahead = lead(linv, n=6) - lag(linv,n=1)) %>%
  mutate(linv_7m_ahead = lead(linv, n=7) - lag(linv,n=1)) %>%
  mutate(linv_8m_ahead = lead(linv, n=8) - lag(linv,n=1)) %>%
  mutate(linv_9m_ahead = lead(linv, n=9) - lag(linv,n=1)) %>%
  mutate(linv_10m_ahead = lead(linv, n=10) - lag(linv,n=1)) %>%
  mutate(linv_11m_ahead = lead(linv, n=11) - lag(linv,n=1)) %>%
  mutate(linv_12m_ahead = lead(linv, n=12) - lag(linv,n=1)) %>%
  mutate(linv_1m_behind = lag(linv, n=1) - lag(linv, n=2) ) %>%
  #New Orders
  mutate(lnew_1m_ahead = lead(lnew, n=1) - lag(lnew,n=1)) %>%
  mutate(lnew_2m_ahead = lead(lnew, n=2) - lag(lnew,n=1)) %>%
  mutate(lnew_3m_ahead = lead(lnew, n=3) - lag(lnew,n=1)) %>%
  mutate(lnew_4m_ahead = lead(lnew, n=4) - lag(lnew,n=1)) %>%
  mutate(lnew_5m_ahead = lead(lnew, n=5) - lag(lnew,n=1)) %>%
  mutate(lnew_6m_ahead = lead(lnew, n=6) - lag(lnew,n=1)) %>%
  mutate(lnew_7m_ahead = lead(lnew, n=7) - lag(lnew,n=1)) %>%
  mutate(lnew_8m_ahead = lead(lnew, n=8) - lag(lnew,n=1)) %>%
  mutate(lnew_9m_ahead = lead(lnew, n=9) - lag(lnew,n=1)) %>%
  mutate(lnew_10m_ahead = lead(lnew, n=10) - lag(lnew,n=1)) %>%
  mutate(lnew_11m_ahead = lead(lnew, n=11) - lag(lnew,n=1)) %>%
  mutate(lnew_12m_ahead = lead(lnew, n=12) - lag(lnew,n=1)) %>%
  mutate(lnew_1m_behind = lag(lnew, n=1) - lag(lnew, n=2) ) %>% 
  #TCU index
  mutate(tcu_1m_ahead = lead(tcu, n=1) - lag(tcu,n=1)) %>%
  mutate(tcu_2m_ahead = lead(tcu, n=2) - lag(tcu,n=1)) %>%
  mutate(tcu_3m_ahead = lead(tcu, n=3) - lag(tcu,n=1)) %>%
  mutate(tcu_4m_ahead = lead(tcu, n=4) - lag(tcu,n=1)) %>%
  mutate(tcu_5m_ahead = lead(tcu, n=5) - lag(tcu,n=1)) %>%
  mutate(tcu_6m_ahead = lead(tcu, n=6) - lag(tcu,n=1)) %>%
  mutate(tcu_7m_ahead = lead(tcu, n=7) - lag(tcu,n=1)) %>%
  mutate(tcu_8m_ahead = lead(tcu, n=8) - lag(tcu,n=1)) %>%
  mutate(tcu_9m_ahead = lead(tcu, n=9) - lag(tcu,n=1)) %>%
  mutate(tcu_10m_ahead = lead(tcu, n=10) - lag(tcu,n=1)) %>%
  mutate(tcu_11m_ahead = lead(tcu, n=11) - lag(tcu,n=1)) %>%
  mutate(tcu_12m_ahead = lead(tcu, n=12) - lag(tcu,n=1)) %>%
  mutate(tcu_1m_behind = lag(tcu, n=1) - lag(tcu, n=2) ) %>% 
  #ISM Manufacturing
  mutate(ism_man_1m_ahead = lead(ism_man, n=1) - lag(ism_man, n=1)) %>%
  mutate(ism_man_2m_ahead = lead(ism_man, n=2) - lag(ism_man, n=1)) %>%
  mutate(ism_man_3m_ahead = lead(ism_man, n=3) - lag(ism_man, n=1)) %>%
  mutate(ism_man_4m_ahead = lead(ism_man, n=5) - lag(ism_man, n=1)) %>%
  mutate(ism_man_5m_ahead = lead(ism_man, n=5) - lag(ism_man, n=1)) %>%
  mutate(ism_man_6m_ahead = lead(ism_man, n=6) - lag(ism_man, n=1)) %>%
  mutate(ism_man_7m_ahead = lead(ism_man, n=7) - lag(ism_man, n=1)) %>%
  mutate(ism_man_8m_ahead = lead(ism_man, n=8) - lag(ism_man, n=1)) %>%
  mutate(ism_man_9m_ahead = lead(ism_man, n=9) - lag(ism_man, n=1)) %>%
  mutate(ism_man_10m_ahead = lead(ism_man, n=10) - lag(ism_man, n=1)) %>%
  mutate(ism_man_11m_ahead = lead(ism_man, n=11) - lag(ism_man, n=1)) %>%
  mutate(ism_man_12m_ahead = lead(ism_man, n=12) - lag(ism_man, n=1)) %>% 
  #ISM Non Manufacturing
  mutate(ism_nonman_1m_ahead = lead(ism_nonman, n=1) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_2m_ahead = lead(ism_nonman, n=2) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_3m_ahead = lead(ism_nonman, n=3) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_4m_ahead = lead(ism_nonman, n=4) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_5m_ahead = lead(ism_nonman, n=5) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_6m_ahead = lead(ism_nonman, n=6) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_7m_ahead = lead(ism_nonman, n=7) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_8m_ahead = lead(ism_nonman, n=8) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_9m_ahead = lead(ism_nonman, n=9) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_10m_ahead = lead(ism_nonman, n=10) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_11m_ahead = lead(ism_nonman, n=11) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_12m_ahead = lead(ism_nonman, n=12) - lag(ism_nonman, n=1)) %>%
  mutate(ism_nonman_1m_behind = lag(ism_nonman, n=1) - lag(ism_nonman, n=2) ) 




```

1.3 Select time period
```{r, results="hide", include=FALSE}

#Select sample period
macrofin_m_2000_extd = subset(final_agg_macro, date > "1999-11-01" & date < "2023-04-01")  

#Exclude GFC
macrofin_m_2000_extd_excrisis = subset(macrofin_m_2000_extd, date < "2007-12-01" | date > "2009-03-01") 


```



########################################## 
2. IRF's
##########################################

2.1 Industrial Prod 
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(lip_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lip_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lip_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lip_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lip_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lip_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lip_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lip_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lip_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lip_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lip_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lip_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(lip_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lip_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lip_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lip_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lip_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lip_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lip_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lip_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lip_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0,mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(lip_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lip_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lip_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lip_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lip_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lip_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lip_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lip_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lip_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lip_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lip_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lip_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lip_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(lip_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lip_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lip_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lip_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lip_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lip_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lip_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lip_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lip_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0,mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline


# 
# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1




# Local Proj

mod_ip_1 = lm(scale(lip_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lip_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lip_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lip_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lip_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lip_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lip_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lip_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lip_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lip_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lip_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lip_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(lip_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lip_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lip_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lip_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lip_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lip_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lip_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lip_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lip_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lip_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lip_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0,mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0,robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p1=ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("IP") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-1,1) +
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p1<-p1+geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p1



```

2.2 ISM-MAN
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(ism_nonman_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_nonman_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_nonman_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_nonman_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_nonman_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_nonman_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_nonman_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_nonman_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_nonman_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_nonman_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_nonman_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_nonman_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(ism_nonman_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_nonman_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_nonman_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_nonman_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_nonman_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_nonman_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_nonman_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_nonman_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_nonman_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0,mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(ism_nonman_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_nonman_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_nonman_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_nonman_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_nonman_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_nonman_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_nonman_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_nonman_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_nonman_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_nonman_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_nonman_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_nonman_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_nonman_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(ism_nonman_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_nonman_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_nonman_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_nonman_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_nonman_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_nonman_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_nonman_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_nonman_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_nonman_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0,mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline



# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1
# 


#Local Proj


mod_ip_1 = lm(scale(ism_nonman_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_nonman_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_nonman_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_nonman_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_nonman_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_nonman_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_nonman_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_nonman_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_nonman_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_nonman_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_nonman_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_nonman_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(ism_nonman_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_nonman_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_nonman_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_nonman_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_nonman_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_nonman_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_nonman_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_nonman_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_nonman_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_nonman_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_nonman_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0,mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0,robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p2=ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("ISM-MAN") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-0.95,1.05)+
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p2<-p2+geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p2
```

2.3 ISM-non MAN
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(ism_man_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_man_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_man_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_man_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_man_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_man_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_man_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_man_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_man_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_man_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_man_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_man_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(ism_man_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_man_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_man_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_man_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_man_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_man_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_man_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_man_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_man_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0,mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(ism_man_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_man_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_man_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_man_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_man_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_man_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_man_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_man_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_man_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_man_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_man_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_man_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_man_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(ism_man_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_man_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_man_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_man_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_man_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_man_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_man_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_man_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_man_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline



# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1
# 


#Local Proj


mod_ip_1 = lm(scale(ism_man_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(ism_man_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(ism_man_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(ism_man_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(ism_man_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(ism_man_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(ism_man_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(ism_man_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(ism_man_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(ism_man_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(ism_man_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(ism_man_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(ism_man_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(ism_man_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(ism_man_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(ism_man_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(ism_man_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(ism_man_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(ism_man_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(ism_man_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(ism_man_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(ism_man_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(ism_man_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0, mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0, robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p3=ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("ISM-NMAN") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-1.05,0.99)+
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p3 <- p3 + geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p3

```

2.4 Total capacity utilization
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(tcu_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(tcu_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(tcu_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(tcu_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(tcu_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(tcu_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(tcu_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(tcu_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(tcu_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(tcu_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(tcu_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(tcu_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(tcu_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(tcu_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(tcu_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(tcu_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(tcu_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(tcu_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(tcu_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(tcu_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(tcu_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(tcu_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(tcu_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(tcu_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(tcu_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(tcu_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(tcu_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(tcu_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(tcu_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(tcu_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(tcu_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(tcu_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(tcu_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(tcu_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(tcu_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(tcu_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(tcu_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(tcu_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(tcu_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(tcu_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(tcu_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(tcu_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(tcu_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline



# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1
# 


#Local Proj


mod_ip_1 = lm(scale(tcu_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(tcu_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(tcu_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(tcu_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(tcu_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(tcu_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(tcu_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(tcu_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(tcu_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(tcu_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(tcu_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(tcu_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(tcu_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(tcu_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(tcu_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(tcu_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(tcu_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(tcu_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(tcu_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(tcu_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(tcu_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(tcu_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(tcu_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0,mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0,robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p4 = ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("TCU") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-0.99,0.99)+
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p4 <- p4 + geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p4

```

2.5 New orders (capital goods)
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(lnew_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lnew_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lnew_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lnew_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lnew_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lnew_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lnew_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lnew_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lnew_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lnew_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lnew_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lnew_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(lnew_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lnew_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lnew_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lnew_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lnew_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lnew_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lnew_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lnew_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lnew_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(lnew_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lnew_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lnew_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lnew_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lnew_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lnew_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lnew_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lnew_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lnew_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lnew_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lnew_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lnew_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lnew_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(lnew_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lnew_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lnew_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lnew_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lnew_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lnew_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lnew_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lnew_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lnew_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline



# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1
# 


#Local Proj


mod_ip_1 = lm(scale(lnew_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(lnew_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(lnew_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(lnew_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(lnew_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(lnew_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(lnew_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(lnew_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(lnew_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(lnew_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(lnew_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(lnew_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(lnew_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(lnew_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(lnew_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(lnew_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(lnew_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(lnew_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(lnew_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(lnew_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(lnew_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(lnew_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(lnew_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0,mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0,robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p5 = ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("NEW") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-0.99,0.99)+
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p5 <- p5 + geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p5

```

2.6 Business Inventory
```{r, results="hide", include=FALSE}

#With Loan spread

mod_ip_1 = lm(scale(linv_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(linv_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(linv_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(linv_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(linv_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(linv_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(linv_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(linv_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(linv_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(linv_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(linv_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(linv_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(linv_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(linv_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(linv_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(linv_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(linv_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(linv_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(linv_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(linv_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(linv_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12


#Empty matrix
output=matrix( ,ncol=2,nrow=13)
output=as.tibble(output)
output <- output %>% 
  rename(adj_r2=V1) %>% 
  rename(horizon=V2) 


mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$adj_r2 <- x$x
output$horizon <- seq(from=0, to=12, by=1)



#Baseline without loan spread

mod_ip_1 = lm(scale(linv_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(linv_1m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(linv_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(linv_2m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(linv_3m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(linv_3m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(linv_4m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(linv_5m_ahead) ~ + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(linv_5m_ahead) ~   scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(linv_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(linv_6m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(linv_7m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(linv_7m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)



mod_ip_8 = lm(scale(linv_8m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(linv_8m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(linv_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(linv_9m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(linv_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(linv_10m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(linv_11m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(linv_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(linv_12m_ahead) ~  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

mod_1_r <- summary(mod_ip_1)$adj.r.squared
mod_2_r <- summary(mod_ip_2)$adj.r.squared
mod_3_r <- summary(mod_ip_3)$adj.r.squared
mod_4_r <- summary(mod_ip_4)$adj.r.squared
mod_5_r <- summary(mod_ip_5)$adj.r.squared
mod_6_r <- summary(mod_ip_6)$adj.r.squared
mod_7_r <- summary(mod_ip_7)$adj.r.squared
mod_8_r <- summary(mod_ip_8)$adj.r.squared
mod_9_r <- summary(mod_ip_9)$adj.r.squared
mod_10_r <- summary(mod_ip_10)$adj.r.squared
mod_11_r <- summary(mod_ip_11)$adj.r.squared
mod_12_r <- summary(mod_ip_12)$adj.r.squared
x <- c(0, mod_1_r, mod_2_r, mod_3_r, mod_4_r, mod_5_r, mod_6_r, mod_7_r, mod_8_r,  mod_9_r, mod_10_r, mod_11_r, mod_12_r )
x <- as.data.frame(x)

#Add regression coeffecient
output$baseline <- x$x
output$incremental <- output$adj_r2 - output$baseline



# #Plot
# p1=ggplot(output, aes(x = horizon , y = incremental)) + 
#   geom_line( size = 1, color = "darkblue", fill = "white") +
#   theme_bw() +
#   ylab("") +
#   xlab("h - Forecast horizon (months)") +
#   theme(text = element_text(size=8)) +
#   ggtitle("IP") +
#   theme(text = element_text(size=8)) +
#   scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
#   ylim(-0.10,0.30)+
#   geom_hline(yintercept=0, linetype="dashed", color = "red")
# p1
# 


#Local Proj


mod_ip_1 = lm(scale(linv_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_1 = NeweyWest(lm(scale(linv_1m_ahead) ~ scale(loan_spr_fd) +  scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_1, vcov = nw_mod_ip_1 )
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,3]
#standerdised coeffecients
coef_mod_ip_1=lm.beta(mod_ip_1)


mod_ip_2 = lm(scale(linv_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_2 = NeweyWest(lm(scale(linv_2m_ahead) ~ scale(loan_spr_fd) + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_2, vcov = nw_mod_ip_2 )
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,3]
#standerdised coeffecients
coef_mod_ip_2=lm.beta(mod_ip_2)


mod_ip_3 = lm(scale(linv_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_3 = NeweyWest(lm(scale(linv_3m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_3, vcov = nw_mod_ip_3 )
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,3]
#standerdised coeffecients
coef_mod_ip_3=lm.beta(mod_ip_3)


mod_ip_4 = lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_4 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_4, vcov = nw_mod_ip_4 )
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,3]
#standerdised coeffecients
coef_mod_ip_4=lm.beta(mod_ip_4)


mod_ip_5 = lm(scale(linv_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_5 = NeweyWest(lm(scale(linv_5m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_5, vcov = nw_mod_ip_5 )
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,3]
#standerdised coeffecients
coef_mod_ip_5=lm.beta(mod_ip_5)


mod_ip_6 = lm(scale(linv_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_6 = NeweyWest(lm(scale(linv_6m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_6, vcov = nw_mod_ip_6 )
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,3]
#standerdised coeffecients
coef_mod_ip_6=lm.beta(mod_ip_6)



mod_ip_7 = lm(scale(linv_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_7 = NeweyWest(lm(scale(linv_7m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_7, vcov = nw_mod_ip_7 )
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,3]
#standerdised coeffecients
coef_mod_ip_7=lm.beta(mod_ip_7)




mod_ip_8 = lm(scale(linv_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_8 = NeweyWest(lm(scale(linv_8m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_8, vcov = nw_mod_ip_8 )
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,3]
#standerdised coeffecients
coef_mod_ip_8=lm.beta(mod_ip_8)



mod_ip_9 = lm(scale(linv_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_9 = NeweyWest(lm(scale(linv_9m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_9, vcov = nw_mod_ip_9 )
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,3]
#standerdised coeffecients
coef_mod_ip_9=lm.beta(mod_ip_9)



mod_ip_10 = lm(scale(linv_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_10 = NeweyWest(lm(scale(linv_10m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_10, vcov = nw_mod_ip_10 )
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,3]
#standerdised coeffecients
coef_mod_ip_10=lm.beta(mod_ip_10)



mod_ip_11 = lm(scale(linv_11m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_11 = NeweyWest(lm(scale(linv_4m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_11, vcov = nw_mod_ip_11 )
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,3]
#standerdised coeffecients
coef_mod_ip_11=lm.beta(mod_ip_11)



mod_ip_12 = lm(scale(linv_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind), data = macrofin_m_2000_extd)
# NewwyWest standard errors
nw_mod_ip_12 = NeweyWest(lm(scale(linv_12m_ahead) ~ scale(loan_spr_fd)  + scale(termspr) + scale(ffr_r) + scale(linv_1m_behind) , data = macrofin_m_2000_extd), lag = 4, prewhite = F, adjust = T)
coeftest(mod_ip_12, vcov = nw_mod_ip_12 )
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,3]
#standerdised coeffecients
coef_mod_ip_12=lm.beta(mod_ip_12)
coef_mod_ip_12

#Empty matrix
output_a=matrix( ,ncol=2,nrow=13)
output_a=as.tibble(output_a)
output_a <- output_a %>% 
  rename(coeff=V1) %>% 
  rename(se=V2) 

#Add regression coeffecient
output_a[,1] <- rbind(0,mod_ip_1$coefficients[2], mod_ip_2$coefficients[2], mod_ip_3$coefficients[2], mod_ip_4$coefficients[2], mod_ip_5$coefficients[2], mod_ip_6$coefficients[2],mod_ip_7$coefficients[2], mod_ip_8$coefficients[2], mod_ip_9$coefficients[2], mod_ip_10$coefficients[2], mod_ip_11$coefficients[2], mod_ip_12$coefficients[2] )

#Save the NW std error to a vector
robust_mod_ip_1 = coeftest(mod_ip_1, vcov = nw_mod_ip_1 )[,2]
robust_mod_ip_2 = coeftest(mod_ip_2, vcov = nw_mod_ip_2 )[,2]
robust_mod_ip_3 = coeftest(mod_ip_3, vcov = nw_mod_ip_3 )[,2]
robust_mod_ip_4 = coeftest(mod_ip_4, vcov = nw_mod_ip_4 )[,2]
robust_mod_ip_5 = coeftest(mod_ip_5, vcov = nw_mod_ip_5 )[,2]
robust_mod_ip_6 = coeftest(mod_ip_6, vcov = nw_mod_ip_6 )[,2]
robust_mod_ip_7 = coeftest(mod_ip_7, vcov = nw_mod_ip_7 )[,2]
robust_mod_ip_8 = coeftest(mod_ip_8, vcov = nw_mod_ip_8 )[,2]
robust_mod_ip_9 = coeftest(mod_ip_9, vcov = nw_mod_ip_9 )[,2]
robust_mod_ip_10 = coeftest(mod_ip_10, vcov = nw_mod_ip_10 )[,2]
robust_mod_ip_11 = coeftest(mod_ip_11, vcov = nw_mod_ip_11 )[,2]
robust_mod_ip_12 = coeftest(mod_ip_12, vcov = nw_mod_ip_12 )[,2]

# Add NW std errors
output_a[,2] <- rbind(0,robust_mod_ip_1[2], robust_mod_ip_2[2], robust_mod_ip_3[2], robust_mod_ip_4[2], robust_mod_ip_5[2], robust_mod_ip_6[2], robust_mod_ip_7[2], robust_mod_ip_8[2],  robust_mod_ip_9[2], robust_mod_ip_10[2], robust_mod_ip_11[2], robust_mod_ip_12[2]  )

#Add CI
output_a <- output_a %>% 
  mutate(upper_lim=coeff+1.96*se) %>% 
  mutate(lower_lim=coeff-1.96*se) %>% 
  mutate(index=seq(from=0, to=12, by=1))


#Combine LP and Incremental R2
output <- cbind(output, output_a)


#Plot
p6 = ggplot(output, aes(x = index , y = coeff) ) + 
  geom_line(aes(x = horizon , y = incremental), size = 1, color = "grey") +
  geom_line(aes(x = index , y = coeff), size = 1, color = "darkblue", fill = "white") +
  theme_bw() +
  ylab("") +
  xlab("h - Forecast horizon (months)") +
  theme(text = element_text(size=8)) +
  ggtitle("INV") +
  theme(text = element_text(size=8)) +
  scale_x_discrete(limits=c("1","2","3","4","5","6","7","8","9","10","11","12"))+
  ylim(-0.99,0.99)+
  geom_hline(yintercept=0, linetype="dashed", color = "red")

p6 <- p6 + geom_ribbon(aes(ymin=lower_lim, ymax=upper_lim), linetype=1, alpha=0.2, fill="red")
p6

```



########################################## 
3. Combine into Figure 5
########################################## 

3.1 Figure 5
```{r, results="hide", include=FALSE}

library(ggpubr)

ggarrange(p1, p2, p3, p4, p5, p6, nrow=2, ncol=3)

```



